#include "http/http_server.h"
#include "log.h"
#include "address.h"
#include "iomanager.h"

static johnsonli::Logger::ptr g_logger = LOG_ROOT();

void run()
{
    g_logger->setLevel(johnsonli::LogLevel::ERROR);

    johnsonli::Address::ptr addr = johnsonli::Address::LookupAnyIPAddress("0.0.0.0:8020");

    johnsonli::http::HttpServer::ptr server(new johnsonli::http::HttpServer(true));
    
    while(!server->bind(addr))
    {
        LOG_ERROR(g_logger) << "bind error";
        sleep(2);
    }

    server->start();
}

int main()
{
    johnsonli::IOManager iom(1);
    iom.schedule(run);
}